package com.ketai.web;

import com.alibaba.fastjson.JSON;
import com.ketai.pojo.CActivity;
import com.ketai.service.CActivityService;
import com.ketai.service.impl.CActivityServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author:石林昭
 * @Description:
 * @Date:Create In 2022-08-04 10:35
 **/
@WebServlet("/CActivityServlet")
public class CActivityServlet extends HttpServlet {
    CActivityService cActivityService = new CActivityServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String opr = req.getParameter("opr");
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");
        if ("list".equals(opr)){
            String cid = req.getParameter("cid");
            List<CActivity> cActivity = cActivityService.checkClassify(cid);
            String cacrivitylist= JSON.toJSONString(cActivity);
            resp.getWriter().write(cacrivitylist);

        }else  if ("all".equals(opr)){
            List<CActivity> cActivityList = cActivityService.AllCheckClf();
            String cacrivitylist= JSON.toJSONString(cActivityList);
            resp.getWriter().write(cacrivitylist);

        }else  if ("ptl".equals(opr)){
            String id = req.getParameter("id");

        }
    }
}
